<template>
  <div class="view-fill">
    <div
      v-show="!assetApplicationDetailInfo.visible"
      class="app-container-flex"
    >
      <NewFullScreen
        v-model="showDialog"
        :title="title"
        :btn-list="fullInfo.btnList"
        :needReturn="!$route.query.processInstanceId"
        @returnBack="$emit('returnModify')"
      >
        <div class="model-panel">
          <div class="model-panel-title">
            <p>{{ $t('basic_information') }}</p>
          </div>
          <div class="model-panel-body">
            <!-- form -->
            <page-form
              class="paddingBox order-model-formBox flex_wrap_start_start"
              v-model:ref-obj="formInfo.ref"
              :disabled="formInfo.disabled"
              :data="formInfo.data"
              :field-list="formInfo.fieldList"
              :rules="formInfo.rules"
              :label-width="formInfo.labelWidth"
            >
              <template v-slot:form-supplierName>
                <el-input
                  v-model="formInfo.data.supplierName"
                  class="not-mongolia"
                  type="input"
                  placeholder="请选择供应商"
                  :disabled="true"
                >
                  <template #append>
                    <el-icon @click="selectSupplier"><MoreFilled /></el-icon>
                  </template>
                </el-input>
              </template>
              <template v-slot:form-deptName>
                <el-input
                  v-model="formInfo.data.deptName"
                  class="not-mongolia"
                  type="input"
                  :disabled="true"
                  placeholder="请选择部门"
                >
                  <template #append>
                    <el-icon @click="openDeptWindow"><MoreFilled /></el-icon>
                  </template>
                </el-input>
              </template>
              <template v-slot:form-invoiceDate="scope">
                <el-date-picker
                  v-model="formInfo.data.invoiceDate"
                  type="date"
                  value-format="YYYY-MM-DD"
                  placeholder="请选择日期"
                />
              </template>
            </page-form>
          </div>
        </div>

        <div class="model-panel">
          <div class="model-panel-title">
            <Tooltip :text="$t('detailInfo')"></Tooltip>
          </div>
          <div class="model-panel-body">
            <!-- 条件栏 -->
            <page-filter
              v-model:query="filterInfo.query"
              :filter-list="filterInfo.list"
            >
              <template v-slot:filter-addProduct>
                <el-button :disabled="!canAddProduct" @click="addProduct"
                  >添加资产</el-button
                >
              </template>

              <template v-slot:filter-removeProduct>
                <el-button :disabled="!canRemoveProduct" @click="removeProduct"
                  >删除资产</el-button
                >
              </template>
            </page-filter>
            <div class="flex_full_item">
              <el-form ref="tableForm" :model="tableInfo" style="width: 100%">
                <!-- 表格 -->
                <page-table
                  class="table-scroll-hidden"
                  :refresh="tableInfo.refresh"
                  :init-curpage="tableInfo.initCurpage"
                  v-model:data="tableInfo.data"
                  :pager="false"
                  :summary="true"
                  :summary-field-list="tableInfo.summaryFieldList"
                  :tab-index="false"
                  :query="filterInfo.query"
                  :field-list="tableInfo.fieldList"
                  :handle="tableInfo.handle"
                  :row-class-name="tableRowClassName"
                  :isDynamic="true"
                  @handleEvent="handleEvent"
                >
                  <template v-slot:col-preAssetName="scope">
                    {{ scope.row.preAssetName }}
                  </template>
                  <template v-slot:col-assetApplicationNo="scope">
                    <span
                      class="slip-edit"
                      @click="showAssetApplicationDetail(scope.row)"
                      >{{ scope.row.assetApplicationNo }}</span
                    >
                  </template>
                  <template v-slot:col-qty="scope">
                    <el-form-item
                      v-if="scope.$index >= 0"
                      :prop="`data.${scope.$index}.qty`"
                      :rules="
                        scope.$index >= 0
                          ? [
                              {
                                validator: $validate.positive,
                                trigger: 'blur',
                              },
                            ]
                          : []
                      "
                    >
                      <el-input-number
                        style="width: 100%"
                        v-model.lazy="scope.row.qty"
                        clearable
                        controls-position="right"
                        :disabled="formInfo.data.invoiceType == 1"
                        :precision="0"
                        :min="0"
                        :max="scope.row.availableQty || 99999999"
                      />
                    </el-form-item>
                  </template>
                  <template v-slot:col-sumAmount="scope">
                    <el-form-item
                      v-if="scope.$index >= 0"
                      :prop="`data.${scope.$index}.sumAmount`"
                    >
                      <el-input-number
                        style="width: 100%"
                        v-model.lazy="scope.row.sumAmount"
                        clearable
                        :disabled="formInfo.data.invoiceType == 1"
                        controls-position="right"
                        :precision="systemConfig.qty_show_precision"
                        :min="0"
                        :max="scope.row.availableSumAmount || 99999999"
                      />
                    </el-form-item>
                  </template>
                </page-table>
              </el-form>
            </div>
          </div>
        </div>
      </NewFullScreen>
    </div>
    <!--资产选择-->
    <Select-asset
      v-if="selectEquipmentInfo.visible"
      v-model:show-dialog="selectEquipmentInfo.visible"
      :query="selectEquipmentInfo.query.queryMap"
      :query-params="selectEquipmentInfo.query.queryParams"
      :check-box="true"
      :api="selectEquipmentInfo.api"
      :tableKey="selectEquipmentInfo.tableKey"
      @callback="callBackEquipment"
    />
    <!-- 选择部门 -->
    <select-dept
      v-if="selectDeptInfo.visible"
      v-model:show-dialog="selectDeptInfo.visible"
      :query="selectDeptInfo.query"
      :check-box="false"
      :highlight-row="true"
      :saveEmpty="true"
      @callback="selectDeptCallback"
    />
    <SelectSupplier
      v-if="supplierInfo.visible"
      v-model:show-dialog="supplierInfo.visible"
      :query="supplierInfo.query"
      :check-box="false"
      :highlight-row="true"
      :api="supplierInfo.api"
      @callback="selectSupplierCallback"
    />
    <!-- 资产申购论证 -->
    <asset-application-detail
      v-if="assetApplicationDetailInfo.visible"
      :id="assetApplicationDetailInfo.id"
      v-model:visible="assetApplicationDetailInfo.visible"
      :title="assetApplicationDetailInfo.title"
    />
  </div>
</template>

<script setup name="purchInvoiceModify">
import {
  createPurchInvoiceOrder,
  createPurchInvoiceOrderAndSave,
  createPurchInvoiceOrderFlowSaveAndSubmit,
  updatePurchInvoiceOrder,
  methodPurchInvoiceOrder,
  getPurchInvoiceOrderById,
  getPurchInvoiceOrderDetailCustomizeListAll,
  getPurchInvoiceOrderDetailByContractId,
  getAssetStoreOrderDetailCustomizeListPage,
} from '@/api/asset.js'
import { getAssetCardCustomizePage, getDeptPage } from '@/api/core.js'
import { getSupplierPage } from '@/api/core'
import { getCustomizeSetting } from '@/api/customize'
import moment from 'moment'
const AssetApplicationDetail = defineAsyncComponent(() =>
  import('@/views/asset/assetManage/assetApplication/details')
)

const { proxy } = getCurrentInstance()
const emits = defineEmits()
const props = defineProps([
  'tableKey',
  'visible',
  'title',
  'orderId',
  'tableData',
  'contractId',
  'contractNo',
  'flowFormType',
  'id',
])

const formRefs = ref([])
const formInfo = ref({
  ref: null,
  data: {
    // orderNo: "",
    invoiceType: '',
    invoiceDate: moment(new Date()).format('YYYY-MM-DD'),
  },
  fieldList: [
    // 系统单据号：000001(自动生成)
    // *开票日期：2023-4-11       *纸质发票号：000001(手动录入)     *供应商：(手动选择)    *职能部门:（手动选择 ）   合同号：(选择合同..也可手动输入合同号)
    // 发票类型： 入库单/原值增加
    // *发票金额：(根据明细金额汇总)        备注：
    // {
    //   label: "系统单据号",
    //   value: "orderNo",
    //   type: "input",
    //   disabled: true,
    // },
    {
      label: '发票类型',
      value: 'invoiceType',
      type: 'select-model',
      code: 'asset_purch_invoice_order_type',
      // 入库单0  原值1
    },
    { label: '供应商', value: 'supplierName', type: 'slot' },
    { label: '职能部门', value: 'deptName', type: 'slot' },
    { label: '开票日期', value: 'invoiceDate', type: 'slot' },
    { label: '纸质发票号', value: 'invoiceNumber', type: 'input' },
    { label: '合同号', value: 'contractNumber', type: 'input' },
    {
      label: '发票金额',
      value: 'sumAmount',
      type: 'input',
      disabled: true,
    },
    {
      label: '备注',
      value: 'remark',
      type: 'textarea',
    },
  ],
  rules: {
    orderNo: [{ required: true, message: '请输入系统单据号', trigger: 'blur' }],
    invoiceType: [
      { required: true, message: '请选择发票类型', trigger: 'change' },
    ],
    invoiceDate: [
      { required: true, message: '请选择开票日期', trigger: 'change' },
    ],
    invoiceNumber: [
      { required: true, message: '请输入纸质发票号', trigger: 'blur' },
    ],
    supplierName: [
      { required: true, message: '请选择供应商', trigger: 'change' },
    ],
    deptName: [
      { required: true, message: '请选择职能部门', trigger: 'change' },
    ],
    sumAmount: [{ required: true, message: '请输入发票金额', trigger: 'blur' }],
  },
  labelWidth: '120px',
})
// 过滤相关配置
const filterInfo = ref({
  sortArr: [],
  copyQueryMap: {},
  query: {
    queryMap: {
      orderId: {
        queryType: 'EQUALS',
        queryCategory: 'AND',
        value: null,
      },
    },
    queryParams: {
      needPendPurchQty: true,
    },
  },
  list: [
    { type: 'slot', label: '添加资产', value: 'addProduct' },
    { type: 'slot', label: '删除资产', value: 'removeProduct' },
  ],
})
// 原值调整保存需要的表格 没合并数据
// const tableInfoOld = ref({
//   data:[]
// })
// 表格相关
const tableInfo = ref({
  refresh: 1,
  initCurpage: 1,
  data: [],
  api: undefined,
  selections: [],
  summaryFieldList: [
    { value: 'qty', formatter: proxy.$fn.qtyFormatter },
    { value: 'price', show: 'false' },
    { value: 'sumAmount', formatter: proxy.$fn.TripartiteMethod },
  ],
  fieldList: [],
  applicationFieldList: [],
  handle: {
    fixed: 'right',
    label: '操作',
    width: '150',
    btList: [
      {
        label: '删除',
        popconfirmText: '删除后将改变数据,是否继续？',
        event: removeProduct,
        show: true,
      },
    ],
  },
})
const fullInfo = ref({
  btnList: [
    {
      label: '保存并提交',
      event: saveAndSubmit,
      show:
        !props.orderId &&
        !props.id &&
        proxy.$permission('purchInvoiceOrder:saveAndSubmit') &&
        !props.flowFormType,
    },
    { label: '保存', event: save, show: !props.flowFormType },
  ],
})
const selectEquipmentInfo = ref({
  visible: false,
  query: {
    queryMap: {
      // assetStatus: {
      //   queryType: "IN",
      //   queryCategory: "AND",
      //   value: "1,3",
      // },
      status: {
        queryType: 'IN',
        queryCategory: 'AND',
        value: '3',
      },
      // 入库单是 deptId  原值增加是manageDeptId
      // manageDeptId: {
      //   queryType: "IN",
      //   queryCategory: "AND",
      //   value: "",
      // },
      supplierId: {
        queryType: 'IN',
        queryCategory: 'AND',
        value: '',
      },
    },
    queryParams: {
      isAdjust: 1,
    },
  },
  api: 'getAssetCardCustomizePage',
  tableKey:
    'assetPurchInvoiceOrderModifyAdjustList-com.slip.spd.entity.vo.core.CoreAssetVO',
})

const selectDeptInfo = ref({
  visible: false,
  query: {
    deptAuth: 'id',
  },
  api: 'getDeptPage',
})
const supplierInfo = ref({
  visible: false,
  query: {
    id: '',
    searchType: 'org',
    searchField: 'supplierId',
    supplierAuth: 'supplierId',
  },
  api: getSupplierPage,
})
const assetApplicationDetailInfo = ref({
  visible: false,
  id: '',
  title: '申论详情',
})
const index = ref('')
const systemConfig = ref(proxy.$store.state.permission.systemConfig)
const licencesSystemConfig = ref('')

const showDialog = computed({
  get() {
    return props.visible
  },
  set(newValue) {
    emits('update:visible', newValue) // 更新父组件visible
  },
})

const canAddProduct = computed(() => {
  return (
    formInfo.value.data.supplierId &&
    formInfo.value.data.invoiceType !== '' &&
    formInfo.value.data.deptId
  )
})
const canRemoveProduct = computed(() => {
  return tableInfo.value.selections.length
})

watch(
  () => formInfo.value.data.invoiceType,
  (val) => {
    console.log(val)
    tableInfo.value.data = []
    // tableInfoOld.value.data = [];
    tableInfo.value.selections = []
    selectEquipmentInfo.value.api =
      val == 1
        ? getAssetCardCustomizePage
        : getAssetStoreOrderDetailCustomizeListPage
    selectEquipmentInfo.value.tableKey =
      val == 1
        ? 'assetPurchInvoiceOrderModifyAdjustList-com.slip.spd.entity.vo.core.CoreAssetVO'
        : 'assetPurchInvoiceOrderModifyStoreList-com.slip.spd.entity.vo.asset.AssetStoreOrderDetailVO'
    if (props.orderId || props.id) {
      selectEquipmentInfo.value.query.queryParams['orderIdNotEqual'] = ''
    }
    // selectDeptInfo.value.api = val == 1 ? "getDeptPage" : "getDeptPage";
    getCustomize(false)
  }
)

watch(
  () => tableInfo.value.data,
  () => {
    formInfo.value.data.sumAmount = 0
    tableInfo.value.data.forEach((row) => {
      let amount = 0
      if (formInfo.value.data.invoiceType == 0) {
        amount = proxy.$fn.accMul(
          1,
          // row.qty,
          parseFloat(row.sumAmount == null ? 0 : row.sumAmount)
        )
      } else {
        amount = proxy.$fn.accMul(
          1,
          parseFloat(row.sumAmount == null ? 0 : row.sumAmount)
        )
      }
      row.sumAmount = amount
      formInfo.value.data.sumAmount += amount
    })
  },
  {
    deep: true,
  }
)

onMounted(() => {
  formRefs.value = [proxy.$refs['tableForm'], formInfo.value.ref]
})

setData()
function setData() {
  let obj = {
    sumAmount: {
      label: '开票金额',
      value: 'sumAmount',
      type: 'slot',
      minWidth: '150px',
      hidden: true,
    },
    price: {
      label: '单价',
      value: 'price',
      type: 'slot',
      minWidth: '150px',
      permission: !proxy.$permission('assetPurchOrder:price'),
      hidden: true,
    },
    assetName: {
      label: '资产名称',
      value: 'assetName',
      type: 'column',
      hidden: true,
    },
  }
  tableInfo.value.fieldList = Object.values({
    ...proxy.$fn.deepClone(proxy.$fieldfList.FieldList),
    ...obj,
  })
  getCustomize(true)
}
function changeValidate(value, str, ref) {
  setTimeout(() => {
    proxy.$refs[ref].clearValidate(str)
  }, 30)
}
function selectSupplier() {
  // 供应商
  supplierInfo.value.visible = true
}
// 触发事件
function handleEvent(event, data) {
  switch (event) {
    case 'tableCheck':
      tableInfo.value.selections = [...data]
      break
  }
}
//添加产品按钮
function addProduct() {
  selectEquipmentInfo.value.query.queryMap.supplierId.value =
    formInfo.value.data.supplierId

  if (formInfo.value.data.invoiceType == 1) {
    delete selectEquipmentInfo.value.query.queryMap['deptId']
    selectEquipmentInfo.value.query.queryMap['manageDeptId'] = {
      queryType: 'IN',
      queryCategory: 'AND',
      value: formInfo.value.data.deptId,
    }
    let idNotIn = tableInfo.value.data.map(function (item) {
      return item.assetAdjustOrderDetailId
    })
    selectEquipmentInfo.value.query.queryParams[
      'assetAdjustOrderDetailIdNotIn'
    ] = idNotIn.toString()
  } else {
    let idNotIn = tableInfo.value.data.map(function (item) {
      return item.assetStoreOrderDetailId
    })
    delete selectEquipmentInfo.value.query.queryMap['manageDeptId']
    selectEquipmentInfo.value.query.queryMap['deptId'] = {
      queryType: 'IN',
      queryCategory: 'AND',
      value: formInfo.value.data.deptId,
    }
    selectEquipmentInfo.value.query.queryMap['id'] = {
      queryType: 'NOT_IN',
      queryCategory: 'AND',
      value: idNotIn.toString(),
    }
  }
  if (props.orderId || props.id) {
    selectEquipmentInfo.value.query.queryParams['orderIdNotEqual'] =
      formInfo.value.data.id
  }
  selectEquipmentInfo.value.visible = true
}

function callBackEquipment(rows) {
  if (rows && rows.length) {
    const data = rows.map(function (item) {
      if (formInfo.value.data.invoiceType == 1) {
        return {
          ...item,
          assetId: item.id,
          assetCode: item.assetCode || item.code,
          qty: item.qty || undefined,
          price: item.price || undefined,
          assetAdjustOrderNo: item.orderNo,
          preAssetName: item.assetName,
        }
      } else {
        return {
          ...item,
          assetStoreOrderDetailId: item.id,
          qty: item.qty || undefined,
          price: item.price || undefined,
          assetStoreOrderNo: item.orderNo,
          preAssetName: item.commonName,
          sumAmount: item.availableSumAmount,
        }
      }
    })
    // 原值增加可能数据相同 单价不同 所以要合并数据 累加金额
    let newArr = []
    data.forEach((item) => {
      let dataItem = item
      if (newArr.length > 0) {
        let filterValue = newArr.filter((v) => {
          return v.id === dataItem.id
        })
        if (filterValue.length > 0) {
          newArr.forEach((n) => {
            if (n.id === filterValue[0].id) {
              n.price = filterValue[0].price + dataItem.price
              n.sumAmount = filterValue[0].sumAmount + dataItem.sumAmount
              n.assetAdjustOrderDetailId =
                filterValue[0].assetAdjustOrderDetailId +
                ',' +
                dataItem.assetAdjustOrderDetailId
            }
          })
        } else {
          newArr.push(dataItem)
        }
      } else {
        newArr.push(dataItem)
      }
    })
    console.log('newArr', newArr)
    // tableInfoOld.value.data = data.concat(tableInfoOld.value.data);
    tableInfo.value.data = newArr.concat(tableInfo.value.data)
  }
}
//删除产品
function removeProduct(row = undefined) {
  if (row.id && row) {
    tableInfo.value.data = tableInfo.value.data.filter((item) => row !== item)
    // tableInfoOld.value.data = tableInfoOld.value.data.filter((item) => row.id !== item.id);
  } else {
    proxy
      .$confirm('删除后将改变数据,是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
      .then(() => {
        tableInfo.value.data = tableInfo.value.data.filter(
          (row) => !tableInfo.value.selections.includes(row)
        )
        // tableInfoOld.value.data = tableInfoOld.value.data.filter(
        //   (row) => !tableInfo.value.selections.includes(row)
        // );
      })
  }
}

function selectSupplierCallback(data) {
  if (data.supplierId !== formInfo.value.data.supplierId) {
    formInfo.value.data.supplierId = data.supplierId
    formInfo.value.data.supplierName = data.supplierName
    tableInfo.value.data = []
  }
}

function showAssetApplicationDetail(row) {
  assetApplicationDetailInfo.value.id = row.assetApplicationId
  assetApplicationDetailInfo.value.visible = true
}

//打开部门弹窗
function openDeptWindow() {
  // if (formInfo.value.data.invoiceType === "") {
  //   proxy.$message({
  //     message: `请先选择发票类型`,
  //     type: "warning",
  //   });
  //   return;
  // }
  selectDeptInfo.value.visible = true
}
function selectDeptCallback(data) {
  if (data) {
    if (formInfo.value.data.deptId !== data.id) {
      formInfo.value.data.deptName = data.name
      formInfo.value.data.deptId = data.id
      tableInfo.value.data = []
    }
  } else {
    formInfo.value.data.deptName = ''
    formInfo.value.data.deptId = ''
  }
}
// flowData 外部流程页面调用
function saveAndSubmit(flowData) {
  save(true, flowData)
}
function save(isSaveAndSubmit, obj = {}) {
  formRefs.value = [proxy.$refs['tableForm'], formInfo.value.ref]
  proxy.$fn.checkForm(formRefs.value).then(() => {
    const details = tableInfo.value.data.map((item) => {
      return {
        ...item,
        calcQty: item.qty,
      }
    })
    let commonName = details
      .filter((item) => !item.supplierId)
      .map((item) => item.commonName)
    if (commonName.length > 0) {
      proxy.$message({
        duration: 3500,
        type: 'warning',
        showClose: true,
        message: `产品${commonName}供应商不能为空!`,
      })
    } else {
      const data = formInfo.value.data
      data.details = details
      if (data.details.length < 1) {
        proxy.$message({
          duration: 3500,
          type: 'warning',
          showClose: true,
          message: '产品不能为空',
        })
        return
      }
      const api = data.id
        ? updatePurchInvoiceOrder
        : isSaveAndSubmit === true
        ? createPurchInvoiceOrderAndSave
        : createPurchInvoiceOrder
      if (isSaveAndSubmit === true) {
        let flowParams = {
          orderData: data,
          // flowTaskCommentDto和processDefinitionKey为审批流程需要传递的参数
          flowTaskCommentDto: { approvalType: 'submit' },
          processDefinitionKey: 'assetPurchInvoice',
          processInstanceId: obj.processInstanceId,
          taskId: obj.taskId,
        }
        if (!proxy.$route.query.processInstanceId) {
          api(flowParams).then((resp) => {
            if (resp && resp.success) {
              emits('returnModify', false)
              showDialog.value = false
            }
          })
          return
        }
        methodPurchInvoiceOrder(flowParams, 'flowSubmit').then((resp) => {
          if (resp && resp.success) {
            emits('returnModify', false)
            showDialog.value = false
          }
        })
      } else {
        api(data).then((resp) => {
          if (resp && resp.success) {
            emits('returnModify', false)
            showDialog.value = false
          }
        })
      }
    }
  })
}
function _getAssetPurchOrderById(orderId) {
  getPurchInvoiceOrderById(orderId).then((resp) => {
    if (resp && resp.success) {
      formInfo.value.data = resp.data

      getAssetPurchOrderDetails()
    }
  })
}
function getAssetPurchOrderDetails() {
  getPurchInvoiceOrderDetailCustomizeListAll(filterInfo.value.query).then(
    (resp) => {
      if (resp && resp.success) {
        tableInfo.value.data = resp.data
        // tableInfoOld.value.data = resp.data;
        tableInfo.value.data.forEach((item) => {
          item.supplierId = formInfo.value.data.supplierId
          item.supplierName = formInfo.value.data.supplierName
        })
        // tableInfoOld.value.data.forEach((item) => {
        //   item.supplierId = formInfo.value.data.supplierId;
        //   item.supplierName = formInfo.value.data.supplierName;
        // });
      }
    }
  )
}
function getAssetPurchOrderDetailByContractId() {
  getPurchInvoiceOrderDetailByContractId(props.contractId).then((resp) => {
    if (resp && resp.success) {
      tableInfo.value.data = resp.data
    }
  })
}
function tableRowClassName({ row = undefined }) {
  if (row.licenseEndDate) {
    let dataDiff = proxy.$fn.dateDiffLicen(row.licenseEndDate)
    if (dataDiff <= 0) {
      return 'expire-row'
    } else if (Number(licencesSystemConfig.value) >= dataDiff) {
      return 'nearly-row'
    }
  }
  return ''
}
function getCustomize(isGetData) {
  let param = {
    tableKey:
      formInfo.value.data.invoiceType == 1
        ? 'assetPurchInvoiceOrderDetailModifyAdjustList-com.slip.spd.entity.vo.asset.AssetPurchInvoiceOrderDetailVO'
        : props.tableKey ||
          'assetPurchInvoiceOrderDetailModifyList-com.slip.spd.entity.vo.asset.AssetPurchInvoiceOrderDetailVO',
  }
  getCustomizeSetting(param).then((res) => {
    if (res && res.success) {
      let data = res.data
      tableInfo.value.fieldList = proxy.$fn.setFieldList(
        tableInfo.value.fieldList,
        data.detail
      )

      filterInfo.value.query.customizeUserVO = data
      filterInfo.value.query.queryMap.orderId.value = props.orderId || props.id
      if ((props.orderId || props.id) && isGetData) {
        _getAssetPurchOrderById(props.orderId || props.id)
      } else if (props.contractId && props.contractId != -2) {
        getAssetPurchOrderDetailByContractId(props.contractId)
      }
    }
  })
}
// 名称不要做改变，在流程引擎中需要通过refs进行调用
defineExpose({
  save,
  saveAndSubmit,
})
</script>

<style scoped lang="scss">
:deep(.table-scroll-hidden) > .el-table {
  overflow-y: hidden;
}
.model-panel-title {
  display: flex;
  align-items: center;

  .model-tips {
    display: flex;
    align-items: center;
    margin-left: 10px;
    color: #909399;

    .model-tips-nearly,
    .model-tips-expire {
      display: block;
      margin-left: 5px;
      width: 17px;
      height: 17px;
    }

    .model-tips-nearly {
      background: #fceacb;
    }

    .model-tips-expire {
      background: #f5e4e4;
    }
  }
}

:deep(.el-table) {
  .nearly-row {
    background: #fceacb;
  }
  .expire-row {
    background: #f5e4e4;
  }
}
</style>
